import Api from '../../api'
export default{

    state:{
        orderListData:[],
        orderListDataByPage:{}
    },
    actions:{
        // 获取订单信息
        async getOrderListData({commit}){
            const {data:res} = await Api.getOrderList();
            if(res.status == 200) {
                commit("GETORDERLISTDATA",res.data)
            }
            return new Promise((resovle,reject)=>{
                if(res.status == 200) resovle('ok')
                reject('获取失败')
            })
        },
        // 获取订单信息（分页）
        async getOrderListByPage({commit},pagination){
            const {data:res} = await Api.getOrderListByPage(pagination);
            if(res.status == 200) {
                commit("GETORDERLISTDATABYPAGE",res.data)
            }
            return new Promise((resovle,reject)=>{
                if(res.status == 200) resovle(true)
                reject(false)
            })
        },
        // 删除订单信息
        async removeOrderList({commit},oid){
            console.log(commit);
            const {data:res} = await Api.removeOrderList(oid);
            return new Promise((resovle,reject)=>{
                if(res.status == 200) resovle(true)
                reject(false)
            })
        },

    },
    mutations:{
        // 获取球馆信息
        GETORDERLISTDATA(state,orderListData){
            state.orderListData = orderListData;
        },
        GETORDERLISTDATABYPAGE(state,orderListDataByPage){
            state.orderListDataByPage = orderListDataByPage;
        }
        
    },
    getters:{
        orderListData(state){
            return state.orderListData||[];
        },
        orderListDataByPage(state){
            return state.orderListDataByPage||{};
        }
    }
}